<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
#set( $dollarSign = "$" )
#macro (externalLink $href $text)  
<a href="$href">$text</a>
#end
#macro (runtimePageLink $link)
<a href="${link.page.id}.jsf$!{link.x.queryString}">$link.title</a>
#end 
<html xmlns:c="http://java.sun.com/jsp/jstl/core"
	  xmlns:ui="http://java.sun.com/jsf/facelets"
	  xmlns:f="http://java.sun.com/jsf/core"
	  xmlns:h="http://java.sun.com/jsf/html"
      xmlns:clickframes="http://${techspec.domain}"
	  xmlns="http://www.w3.org/1999/xhtml">
<f:loadBundle basename="messages" var="messages" />

<ui:composition template="/WEB-INF/facelets/layout/layout.xhtml">
    <ui:define name="metadata">
      <f:metadata>
#foreach ($param in $page.parameters)
#if ($param.required)
        <f:viewParam id="${param.id}" name="${param.id}" value="#{${page.x.javaId}.${param.id}}"/>
#end
#end
        <f:event type="preRenderView" listener="#{${page.x.javaId}.${page.x.pageLoadActionId}}"/>
      </f:metadata>
    </ui:define>

    <ui:define name="title">${page.title}</ui:define>
    <ui:param name="clickframesPage" value="${page.id}" />
    <ui:define name="page-content">

	  <h2>${page.title}</h2>
	  <!--
		 ${page.description}
	  -->

      <div id="page-navigation" class="grid_2 alpha">
          <ul>
#foreach($linkSet in $page.linkSets)      
#foreach($link in $linkSet.links)
            <li>
#if ($link.internal)
               #runtimePageLink($link)
#else
               #externalLink($link.href $link.title)
#end
            </li>
#end
#end
#foreach($link in $page.links)
            <li>
#if ($link.internal)
               #runtimePageLink($link)
#else
               #externalLink($link.href $link.title)
#end
            </li>
#end
          </ul>
      </div>
	  
	  <div id="page-content" class="grid_10 omega">

	  <clickframes:messages />
### CONTENTS
#foreach ($content in $page.contents)
	  <div class="content">${content.text}</div>
#end

### FORMS
#if ($page.forms.size() > 0)
#foreach($form in $page.forms)
	  <h:form id="${form.id}" #if($form.fileInputs.size()>0) enctype="multipart/form-data" #end>
#if ($form.inputs.size() > 0)
#foreach($input in $form.inputs)
		 <div class="field">
			 <label class="grid_2 alpha">${input.title}</label>
			 <div class="#if ($input.type == 'radio') field-checkbox #else field-input #end grid_4">
				 <clickframes:${page.id}-${form.id}-${input.id} />
			 </div>
			 <div class="field-message grid_4 omega">
				 <clickframes:${page.id}-${form.id}-${input.id}-message />
			 </div>
			 <div class="clear"></div>
		 </div>
#end
#end

		 <div class="actions alpha prefix_2 grid_4">
#foreach ($action in $form.actions)
			 <clickframes:${page.id}-${form.id}-${action.id} />
#end
		 </div>
		 <div class="clear"></div>
	  </h:form>
#end ### FOREACH FORM
#end ### FORMS

### OUTPUTS
#if ($page.outputs.size() > 0)
		 <div id="outputs">
#foreach($output in $page.outputs)
			<div class="output grid_5 alpha">
			   <h3>${output.title}</h3>
			   <table>
#foreach ($entityProperty in ${output.entity.properties})
			   <tr>
				  <th>${entityProperty.title}</th>
				  <td>
#if (${entityProperty.type} == 'FILE')
                                    <h:panelGroup rendered="#{${page.x.javaId}.${output.entity.id}.${entityProperty.id}.valid}">
                                      <a href="${output.entity.id}.download?${output.entity.primaryKey.id}=#{${page.x.javaId}.${output.entity.id}.${output.entity.primaryKey.id}}">Download</a>
                                    </h:panelGroup>
#else
                                    #{${page.x.javaId}.${output.id}.${entityProperty.id}}
#end
				  </td>
			   </tr>
#end
			   </table>
			</div>
#end ### FOREACH OUTPUT
			<div class="clear"></div>
		 </div>
#end ### OUTPUTS

### OUTPUT LISTS
#foreach($outputList in $page.outputLists)
		 <div class="output-list">
			<h3>${outputList.title}</h3>
			<h:dataTable value="#{${page.x.javaId}.${outputList.id}}" var="${outputList.entity.id}">
			   <h:column>
#foreach ($link in ${outputList.links})
#if ($link.internal) ### INTERNAL LINKS
				  <a href="${link.page.id}.jsf${link.x.queryString}">${link.title}</a>
#else ### EXTERNAL LINKS
				  <a href="${link.href}">${link.title}</a>
#end
#end ### FOREACH ENTITY LINK

#if($outputList.actions.size() > 0)
				  <h:form id="defaultForm">
#foreach ($action in $outputList.actions)
					 <h:commandLink 
                           action="#{${page.x.javaId}.${action.id}${outputList.name}}" 
                           actionListener="#{${page.x.javaId}.${outputList.id}Listener}" 
                           value="${action.title}"/>
#end ### FOREACH ENTITY ACTION
				  </h:form>
#end ### ENTITY ACTIONS
			   </h:column>
#foreach ($entityProperty in ${outputList.entity.properties})
			   <h:column>
				  <f:facet name="header">${entityProperty.title}</f:facet>
#if (${entityProperty.type} == 'FILE')
                                  <h:panelGroup rendered="#{${outputList.entity.id}.${entityProperty.id}.valid}">
                                    <a href="${outputList.entity.id}.download?${outputList.entity.primaryKey.id}=#{${outputList.entity.id}.${outputList.entity.primaryKey.id}}">Download</a>
                                  </h:panelGroup>
#else
				  #{${outputList.entity.id}.${entityProperty.id}}
#end
			   </h:column>
#end ### FOREACH ENTITY PROPERTY
            </h:dataTable>
		 </div>
#end ### OUTPUT LISTS
	  </div>

    </ui:define>
</ui:composition>
</html>